package com.acyouzi.leetcode.array;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * 17/9/20 22:17
 *
 * @author sunxu
 */
public class CoinChange {
  public int count = 0;
  public int change(int amount, int[] coins) {
    help(amount,coins,0);
    return count;
  }
  private void help(int amount, int[] coins,int index) {
    if (amount <= 0){
      if (amount == 0) count++;
      return;
    }
    for (int i = index; i < coins.length; i++) {
      if (amount - coins[i] >= 0) help(amount - coins[i], coins,i);
    }
  }

  public static void main(String[] args) {
    System.out.println(new CoinChange().change(5,new int[]{1,2,5}));
  }
}
